1. Technical Field
The present invention relates generally to an improved data processing system and, in particular, to a method and system for improving performance of a program in a data processing system. Still more particularly, the present invention relates to a method, apparatus, and computer instructions for hardware assist for autonomically patching code.
2. Description of Related Art
In a conventional computer system, the processor fetches and executes program instructions stored in a high-speed memory known as cache memory. Instructions fetched from cache memory are normally executed without much delay. However, if the program instruction code requires access to data or instructions located in a memory location other than the high-speed cache memory, a decrease in system performance may result, particularly in a pipelined processor system where multiple instructions are executed at the same time.
Such accesses to data and/or instructions located in a memory location other than the high-speed cache memory may occur when the code of the computer program being executed is not organized to provide contiguous execution of the computer program as much as possible. That is, for example, when the computer program is not organized such that basic blocks of code are not organized in memory in the same sequence in which they are executed. One common approach to reduce the negative impact on system performance is to reorganize program code such that data or instructions accessed or executed by a computer program may be grouped together as close as possible.
Various approaches are known in the art to better organize program code. One approach is proposed by Heisch in “PROFILE-BASED OPTIMIZING POSTPROCESSORS FOR DATA REFERENCES” (U.S. Pat. No. 5,689,712). Heisch teaches optimization of programs by creating an instrumented program to capture effective address trace data for each of the memory references, and then analyzing the access patterns of the effective trace data in order to reorder the memory references to create an optimized program. The instrumented program generates an improved memory address allocation reorder list that indicates an optimal ordering for the data items in the program based upon how they are referenced during program execution.
Another approach to optimize program code is suggested by Pettis et al. in “METHOD FOR OPTIMIZING COMPUTER CODE TO PROVIDE MORE EFFICIENT EXECUTION ON COMPUTERS HAVING CACHE MEMORIES” (U.S. Pat. No. 5,212,794). Pettis teaches running program code with test data to produce statistics in order to determine a new ordering for the code blocks. The new order places code blocks that are often executed after one another close to one another in the memory. However, the above approaches require modification of the original code. That is, the above approaches require that the code itself be modified by overwriting the code.
Moreover, when a portion of code is determined to be in need of patching, the code is typically modified so that that original code is shifted downward in the instruction stream with the reorganized code being inserted above it in the instruction stream. Thus, the original code is again modified from its original form.
Code patching may apply to various types of performance optimization functions. For example, the program may determine to reorganize code at run time. In addition, when a computer system is running slow, code patching may be used to switch program execution to an instrumented interrupt service routine that determines how much time the system is spending in interrupts. Furthermore, when a performance monitoring program wants to build a targeted instruction trace for specific instructions, code patching may also be used to hook each instruction block to produce a trace.
It would be advantageous to have an improved method, apparatus, and computer instructions for autonomically patching code by selectively identifying branch instructions or other types of instructions to optimize performance, and providing a pointer indicating where to branch without modifying the original program code.